﻿namespace EFMLEditor.Internal.Validating.Attributes
{
    using System.Reflection;

    public class ContainsAttribute : ValidatingAttribute
    {
        private readonly string containing;

        public ContainsAttribute(string containing)
        {
            this.containing = containing;
        }

        #region Overrides of ValidatingAttribute

        public override bool Do(object input, ParameterInfo parameter)
        {
            var l = input.ToString();
            if(l.Contains(containing))
            {
                return true;
            }
            this.Message = parameter.Name + " must contains " + containing;
            return false;
        }

        #endregion
    }
}